package com.xls.aclservice.mapper;

import com.xls.aclservice.entity.SysMenu;
import com.xls.aclservice.entity.SysRole;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author xls
 * @since 2021-03-23
 */
public interface SysRoleMapper extends BaseMapper<SysRole> {

    @Select("SELECT\n" +
            "\tm.id,\n" +
            "\tm.parent_id,\n" +
            "\tm.name,\n" +
            "\tm.sort\n" +
            "FROM\n" +
            "\tsys_role_menu rm\n" +
            "\tLEFT JOIN menu m ON rm.menu_id = m.id AND m.is_deleted = 0\n" +
            "WHERE\n" +
            "\trm.role_id = #{id} AND rm.is_deleted = 0")
    List<SysMenu> selectMenus(Long id);
}
